package com.hfdg.process.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfdg.process.mapper.ProcessDataQueryMapper;
import com.hfdg.process.service.ProcessDataService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @ClassName ProcessDataServiceImpl
 * @Description TODO
 * @Author yuelh
 * @Date 2020-2-9 15:04
 * @Version 1.0
 * @Company 会飞的锅工作室
 **/
@Service
public class ProcessDataServiceImpl implements ProcessDataService {
    @Autowired
    ProcessDataQueryMapper processDataQueryMapper;

    @Override
    public PageInfo getPagingProcessDefinition(int offset, int limit, String orderBy, Map<String, Object> params) {
        if(null==orderBy|| StringUtils.isBlank(orderBy)){
            PageHelper.startPage((offset/limit)+1,limit);
        }else{
            PageHelper.startPage((offset/limit)+1,limit,orderBy);
        }
        PageInfo pageInfo =new PageInfo<>(processDataQueryMapper.list(params));
        return pageInfo;
    }

    @Override
    public PageInfo getPagingHistoricalTask(int offset, int limit, String orderBy, Map<String, Object> params) {
        return null;
    }
}
